home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Magazine / GraphicsCards / StormMesa / util / mwmborder.c < prev    next >
C/C++ Source or Header  |  1998-12-15  |  3KB  |  92 lines

  1. /* mwmborder.c */
  2.  
  3.  
  4. /*
  5.  * This function shows how to remove the border, title bar, resize button,
  6.  * etc from a Motif window frame from inside an Xlib-based application.
  7.  *
  8.  * Brian Paul  19 Sep 1995   brianp@ssec.wisc.edu
  9.  *
  10.  * This code is in the public domain.
  11.  */
  12.  
  13.  
  14. #include <X11/Xlib.h>
  15. #include <X11/Xatom.h>
  16.  
  17. #define HAVE_MOTIF
  18. #ifdef HAVE_MOTIF
  19.  
  20. #include <X11/Xm/MwmUtil.h>
  21.  
  22. #else
  23.  
  24. /* bit definitions for MwmHints.flags */
  25. #define MWM_HINTS_FUNCTIONS     (1L << 0)
  26. #define MWM_HINTS_DECORATIONS   (1L << 1)
  27. #define MWM_HINTS_INPUT_MODE    (1L << 2)
  28. #define MWM_HINTS_STATUS        (1L << 3)
  29.  
  30. /* bit definitions for MwmHints.decorations */
  31. #define MWM_DECOR_ALL           (1L << 0)
  32. #define MWM_DECOR_BORDER        (1L << 1)
  33. #define MWM_DECOR_RESIZEH       (1L << 2)
  34. #define MWM_DECOR_TITLE         (1L << 3)
  35. #define MWM_DECOR_MENU          (1L << 4)
  36. #define MWM_DECOR_MINIMIZE      (1L << 5)
  37. #define MWM_DECOR_MAXIMIZE      (1L << 6)
  38.  
  39. typedef struct
  40. {
  41.     unsigned long       flags;
  42.     unsigned long       functions;
  43.     unsigned long       decorations;
  44.     long                inputMode;
  45.     unsigned long       status;
  46. } PropMotifWmHints;
  47.  
  48. #define PROP_MOTIF_WM_HINTS_ELEMENTS    5
  49.  
  50. #endif
  51.  
  52.  
  53.  
  54. /*
  55.  * Specify which Motif window manager border decorations to put on a
  56.  * top-level window.  For example, you can specify that a window is not
  57.  * resizabe, or omit the titlebar, or completely remove all decorations.
  58.  * Input:  dpy - the X display
  59.  *         w - the X window
  60.  *         flags - bitwise-OR of the MWM_DECOR_xxx symbols in X11/Xm/MwmUtil.h
  61.  *                 indicating what decoration elements to enable.  Zero would
  62.  *                 be no decoration.
  63.  */
  64. void set_mwm_border( Display *dpy, Window w, unsigned long flags )
  65. {
  66.    PropMotifWmHints motif_hints;
  67.    Atom prop, proptype;
  68.  
  69.    /* setup the property */
  70.    motif_hints.flags = MWM_HINTS_DECORATIONS;
  71.    motif_hints.decorations = flags;
  72.  
  73.    /* get the atom for the property */
  74.    prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", True );
  75.    if (!prop) {
  76.       /* something went wrong! */
  77.       return;
  78.    }
  79.  
  80.    /* not sure this is correct, seems to work, XA_WM_HINTS didn't work */
  81.    proptype = prop;
  82.  
  83.    XChangeProperty( dpy, w,                         /* display, window */
  84.                     prop, proptype,                 /* property, type */
  85.                     32,                             /* format: 32-bit datums */
  86.                     PropModeReplace,                /* mode */
  87.                     (unsigned char *) &motif_hints, /* data */
  88.                     PROP_MOTIF_WM_HINTS_ELEMENTS    /* nelements */
  89.                   );
  90. }
  91.  
  92.